/**
 * Author: 冯亮亮
 * Remark: 需求计划
 */
lyfdefine(['echarts', 'time-line', 'common/scm-plan-common-choosegoods'], function (echarts, time, scmPlanCommonChoosegoods) {
    return ({
            data: function
                () {
                return {
                    chooseGoodsDialog: false,
                    tableData: [],
                    dataList: [],
                    dialogVisible: false,
                    dialogFormVisible: false,
                    value10: true,
                    value1: '',
                    tableShow: true,
                    warehouseList: [],
                    tmpStartDateList: [],
                    pickerOptions: {
                        shortcuts: [{
                            text: '最近一周',
                            onClick(picker) {
                                const nowDate = new Date();
                                const oneWeekDate = new Date(nowDate - 7 * 24 * 3600 * 1000);
                                let nowDayOfWeek = oneWeekDate.getDay(); // 本周的第几天
                                let nowDay = oneWeekDate.getDate(); // 当前日
                                let nowMonth = oneWeekDate.getMonth(); // 当前月
                                let nowYear = oneWeekDate.getFullYear(); // 当前年
                                let start = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 1)
                                let end = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 7)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近一个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 1);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近三个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 3);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }]
                    },
                    charts: false,
                    cType: false,
                    checked: false,
                    a: '',
                    dialogVisible1: false,
                    dateList: [],
                    tables: [],
                    festivals: [],
                    echartsLoading: false,
                    weekDate: [],
                    exportForm: {
                        pageNum: '',
                        pageSize: '',
                    },
                    needMergeArr: ['skuName'], // 有合并项的列
                    rowMergeArrs: {},
                    pageIndex: 1,
                    pageSize: 10,
                    totalPage: 0,
                    totalCount: 0,
                    importErrInfo: '',
                    dataForm: {
                        areaCodeList: [],
                        startTime: '',
                        quota1: [],
                        quota11: [],
                        layeredCodeList: [],
                        fatherChannelCodeList: [],
                        warehouseCodeList: [],
                        planTypeList: [],
                        chanel: [],
                        unitType: 2,
                        edit: false,
                        skuCodeS: ''
                    },
                    dataListLoading: false,
                    warehouseOptions: [],
                    supplierOptions: [],
                    skuOptions: [],
                    targetOption: [
                        {
                            label: '销售计划量',
                            value: 1
                        }, {
                            label: '预测计划量',
                            value: 2
                        }, {
                            label: '安全库存量',
                            value: 3
                        }, {
                            label: '目标库存数量',
                            value: 4
                        }, {
                            label: '覆盖天数',
                            value: 5
                        }, {
                            label: '本次供应链确认量',
                            value: 6
                        },
                        {
                            label: '本次销售计划确认量',
                            value: 7
                        },
                        {
                            label: '上次供应链确认量',
                            value: 8
                        },
                        {
                            label: '上次销售计划确认量',
                            value: 9
                        }, {
                            label: '采购计划数量',
                            value: 10
                        }, {
                            label: '采购订单数量',
                            value: 11
                        }, {
                            label: '未履约采购数量',
                            value: 12
                        }, {
                            label: '已确认的采购订单数量',
                            value: 13
                        }, {
                            label: '预约在途采购数量',
                            value: 14
                        }, {
                            label: '实际到仓数量',
                            value: 15
                        }, {
                            label: '实际入库数量',
                            value: 16
                        }, {
                            label: '实际销量',
                            value: 17
                        }, {
                            label: '实时库存',
                            value: 18
                        }
                    ],
                    currentPage4: '',
                    value2: ['销售计划量', '预测计划量', '安全库存量', '目标库存数量'],
                    labels: [],
                    props: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad
                    },
                    props2: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad2
                    },
                    // props3: {
                    //     checkStrictly: true,
                    //     multiple: true,
                    //     label: 'name',
                    //     value: 'code',
                    //     lazy: true,
                    //     lazyLoad: this.lazyLoad3
                    // },
                    unitOption: [],
                    dataForm1: {
                        unitType: 2
                    },
                    serArr: [],
                    labels: [],
                    pplanTargetDTOS: [],
                    defaultUnit: '',
                    defaultUnitItem: {
                        name: '销售单位',
                        type: 2
                    },
                    channelList: [],
                    planTypeList: [],
                    isEditMode: false,
                    dialogVisible3: false,
                    activeStep: 1,
                    fileList: [],
                    cancelBtnText: '取消',
                }
            },
            components: {
                scmPlanCommonChoosegoods
            },
            mounted() {
                let _this = this
                let beginOflastWeek = _this.getBeginOflastWeek()
                _this.dataForm.startTime = beginOflastWeek
                _this.dataForm1.startTime = beginOflastWeek
                _this.dataForm.unitType = _this.defaultUnitItem.type
                _this.dataForm1.unitType = _this.defaultUnitItem.type
                _this.getDataList()
                this.getUnit()
                _this.getChannelList()
                _this.getPlanTypeList()
                _this.$http({
                    url: 'scm-plan-admin/api/v1/outService/dateLabels',
                    method: 'get',
                    params: {
                        "startDate": beginOflastWeek
                    }
                }).then(result => {
                    _this.festivals = result.data.data
                    _this.$nextTick(function () {
                        _this.initEcharts();
                        _this.initFestivals();
                    });
                })
            }
            ,
            methods: {
                submitUpload() {
                    let that = this;
                    const loading = this.$loading({
                        lock: true,
                        text: '上传中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    const config = {headers: {'Content-Type': 'multipart/form-data'}}
                    let uploadData = new FormData()
                    uploadData.append("file", this.fileList[0].raw)
                    this.$http.post('scm-plan-admin/api/v1/requirements/import?unitType=' + this.dataForm.unitType, uploadData, config
                    ).then(function (res) {
                        const data = res.data;
                        if (data && data.code === '0') {
                            that.$message.success('上传成功')
                            that.totalCount = 0
                            that.pageIndex = 1
                            that.getDataList()
                            that.activeStep = 3;
                            loading.close();
                        } else {
                            that.$message.error('上传失败')
                            that.importErrInfo = data.msg;
                            that.activeStep = 2;
                            loading.close();
                        }
                        loading.close();
                    }).catch(e => {
                        that.$message.error('上传失败')
                        that.importErrInfo = '服务器异常';
                        that.activeStep = 2;
                        loading.close();
                    });
                },
                //初始化上传接口参数
                handleChangeUpload(file) {
                    var FileExt = file.name.replace(/.+\./, "");
                    if (['xls', 'xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
                        this.importErrInfo = '非excel文件';
                    }
                    this.fileList.push(file)
                    this.activeStep = 2;
                },
                onClickCancelBtn() {
                    this.fileList = [];
                    this.activeStep = 1;
                    this.dialogVisible3 = false;
                    this.importErrInfo = '';
                },
                //关闭上传框
                handleClose(done) {
                    this.$confirm('确认关闭？')
                        .then(_ => {
                            this.fileList = [];
                            this.activeStep = 1;
                            this.dialogVisible3 = false;
                            this.importErrInfo = '';
                            done();
                        })
                        .catch(_ => {
                        });
                },
                resetBtn() {
                    this.activeStep = 1;
                    this.importErrInfo = '';
                    this.fileList = [];
                },
                getChannelList() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/outService/queryByLevel?level=1',
                        method: 'GET'
                    }).then(result => {
                        this.channelList = result.data.data;
                    })
                }
                ,
                getPlanTypeList() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/requirements/planTypes',
                        method: 'GET'
                    }).then(result => {
                        this.planTypeList = result.data.data;
                    })
                },
                getUnit() {
                    this.$http({
                        url: "scm-plan-admin/api/v1/outService/listUnitType",
                        method: 'GET'
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            data.data.forEach(e => {
                                let obj = {}
                                obj.unitType = e.unitType
                                obj.unitName = e.unitName
                                this.unitOption.push(obj);
                            })

                        }
                    })
                    this.$http({
                        url: '/scm-plan-admin/api/v1/outService/stock/factory/type',
                        method: "GET",
                        params: {realWarehouseType: 16},
                    }).then(result => {
                        this.warehouseList = result.data.data
                    })
                }
                ,
                // lazyLoad3(node, resolve) {
                //     if (node.level === 0) {
                //         this.$http({
                //             url: 'scm-plan-admin/api/v1/outService/queryByLevel?level=1',
                //             method: 'GET'
                //         }).then(result => {
                //             const nodes = result.data.data;
                //             resolve(nodes);
                //         })
                //     } else {
                //         let parentCode = node.value
                //         this.$http({
                //             url: 'scm-plan-admin/api/v1/outService/parentChannel?parentChannel=' + parentCode,
                //             method: 'GET'
                //         }).then(result => {
                //             const nodes = result.data.data;
                //             if (nodes) {
                //                 nodes.forEach(e => e.level = 2)
                //             }
                //             resolve(nodes);
                //         })
                //
                //     }
                // },

                lazyLoad2(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/searchAreaByLevels',
                            method: 'POST',
                            data: [1]
                        }).then(result => {
                            const nodes = result.data.data.list;
                            resolve(nodes);
                        })
                    } else {
                        let parentCode = node.value
                        let storeParamDTO = {};
                        storeParamDTO.districtCode = parentCode;
                        //下拉选项框只显示到区域的级别，不显示到办事处  区域的level默认是3
                        if (3 === node.data.level) {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/listStore?pageNum=1&pageSize=9999',
                                method: 'POST',
                                data: JSON.stringify(storeParamDTO)
                            }).then(result => {
                                resolve(result.data.data)
                            })
                        } else {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/searchByParentCode?parentCode=' + parentCode,
                                method: 'GET'
                            }).then(result => {
                                const nodes = result.data.data;
                                resolve(nodes);
                            })
                        }
                    }
                }
                ,
                lazyLoad(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/getCategoryListByLevel?level=2',
                            method: 'POST'
                        }).then(result => {
                            const nodes = result.data.data;
                            resolve(nodes);
                        })
                    } else {
                        let stringList = [];
                        stringList.push(node.value);
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/categoryListByCategoryCodes',
                            method: 'POST',
                            data: stringList
                        }).then(result => {
                            node.check = true;
                            const nodes = (result.data.data)[0].categoryDTOList;
                            const id = (result.data.data)[0].id;
                            if (nodes.length > 0) {
                                resolve(nodes);
                            } else {
                                this.$http({
                                    url: "scm-plan-admin/api/v1/outService/skuListByCategoryId/" + id + "/1/9999",
                                    method: 'GET'
                                }).then(result => {
                                    const node = result.data.data;
                                    resolve(node)
                                })
                            }
                        })
                    }

                }
                ,
                getDataListIndex() {
                    this.pageIndex++
                    this.getDataList()
                }
                ,
                debounce(fn, wait) {
                    var timer = null;
                    return function () {
                        if (timer !== null) {
                            clearTimeout(timer);
                        }
                        timer = setTimeout(fn, wait);
                    }
                }
                ,
                formatPeriod(datePeriod) {
                    let dateArray = datePeriod.split('-');
                    if (dateArray.length === 2) {
                        let startDate = dateArray[0].substr(5)
                        let endDate = dateArray[1].substr(5)
                        return `${startDate}-${endDate}`;
                    } else {
                        return dateArray[0].substr(5)
                    }
                }
                ,
                getDataList() {
                    let _this = this
                    this.tableShow = false
                    this.dataListLoading = true;
                    this.dataForm.pageSize = this.pageSize;
                    this.dataForm.pageNum = this.pageIndex;
                    this.$http({
                        url: "/scm-plan-admin/api/v1/requirements/listByWeek",
                        method: 'POST',
                        data: this.dataForm
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            const result = data.data
                            if (result && result.dateList) {
                                this.weekDate = result.dateList;
                            }
                            let list;
                            if (result && result.infoList) {
                                list = result.infoList;
                            }
                            if (!list) {
                                this.dataList = [];
                                this.totalCount = 0;
                            } else {
                                this.handerDataList(list);
                                this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.dataList); // 处理合并数据
                                this.pageIndex = data.data.pageNum
                                if (data.data.hasNextPage) {
                                    let tmpTotalCount = (data.data.pageNum + 1) * this.pageSize
                                    if (this.totalCount < tmpTotalCount) {
                                        this.totalCount = tmpTotalCount
                                    }
                                }
                                //计算十四周日期
                                this.initWeekDates(this.dataForm.startTime)
                            }
                        } else {
                            this.$message.error(result.data.msg);
                            this.dataList = [];
                            this.totalPage = 0;
                        }
                        this.dataListLoading = false;
                        this.$nextTick(e => {
                            _this.tableShow = true
                        })
                    }).catch(() => {
                        this.dataListLoading = false;
                    })
                }
                ,
                initWeekDates(startTime) {
                    let tmpDateList = []
                    this.tmpStartDateList = []
                    let date = new Date(Date.parse(startTime.replace(/-/g, "/")))
                    tmpDateList.push(date)
                    let tmp = date.valueOf();
                    let tDate;
                    for (let i = 0; i < 13; i++) {
                        tmp = tmp + 7 * 24 * 60 * 60 * 1000
                        tDate = new Date(tmp)
                        tmpDateList.push(tDate)
                    }
                    //将日期转换成yyyy-mm-dd格式
                    let y
                    let m
                    let d
                    for (let i = 0; i < 14; i++) {
                        y = tmpDateList[i].getFullYear();
                        m = tmpDateList[i].getMonth() + 1;
                        d = tmpDateList[i].getDate();
                        this.tmpStartDateList[i] = y + '-' + m + '-' + d;
                    }
                }
                ,
                // 关闭窗口
                closeChooseGoodsDialog() {
                    this.chooseGoodsDialog = false
                },
                //查看日志
                choiceAllocationDetail() {
                    this.chooseGoodsDialog = true
                    this.$nextTick(() => {
                        this.$refs.scmPlanCommonChoosegoods.getDataList(2)
                    })
                },
                rowMergeHandle(arr, data) {
                    if (!Array.isArray(arr) && !arr.length) return false;
                    if (!Array.isArray(data) && !data.length) return false;
                    let needMerge = {};
                    arr.forEach(i => {
                        needMerge[i] = {
                            rowArr: [],
                            rowMergeNum: 0
                        };
                        data.forEach((item, index) => {
                            if (index === 0) {
                                needMerge[i].rowArr.push(1);
                                needMerge[i].rowMergeNum = 0;
                            } else {
                                if (item[i] === data[index - 1][i]) {
                                    needMerge[i].rowArr[needMerge[i].rowMergeNum] += 1;
                                    needMerge[i].rowArr.push(0);
                                } else {
                                    needMerge[i].rowArr.push(1);
                                    needMerge[i].rowMergeNum = index;
                                }
                            }
                        });
                    });
                    return needMerge;
                }
                ,
                mergeAction(val, rowIndex, colData) {
                    let _row = this.rowMergeArrs[val].rowArr[rowIndex];
                    let _col = _row > 0 ? 1 : 0;
                    return [_row, _col];
                }
                ,
                arraySpanMethod({row, column, rowIndex, columnIndex}) {
                    // 没办法循环判断具体是那一列 所以就只好写了多个if
                    // if (column.property === 'channel') return this.mergeAction('skuName', rowIndex, column);
                    // if (column.property === 'area') return this.mergeAction('skuName', rowIndex, column);
                    // if (columnIndex === 0) return this.mergeAction('skuName', rowIndex, column);
                    if (columnIndex === 0 || column.property == 'planTypeName' || column.property == 'warehouseName' || column.property == 'channel' || column.property == 'area' || column.property == 'skuName' || column.property == 'category' || column.property == 'unit') {
                        if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length === 0) {
                            return {
                                rowspan: this.targetOption.length,
                                colspan: 1
                            }
                        } else if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                        if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length === 0) {
                            return {
                                rowspan: this.dataForm.quota1.length,
                                colspan: 1
                            }
                        } else if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                    }
                }
                ,
                isContain(list, item) {
                    if (list.length === 0) {
                        return true
                    }
                    let e = list.find(e => {
                        return e === item
                    })
                    if (e !== undefined) {
                        return true
                    } else {
                        return false
                    }
                }
                ,
                handerDataList(dataList) {
                    let newDataList = [];
                    let _this = this
                    dataList.forEach((item, index, array) => {
                        let confirmQty = []
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 1)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.salesPlanQtyLabel, // 供应商确认量（标识）
                                qtyList: item.salesPlanQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 2)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.forecastPlanQtyLabel, // 供应商确认量（标识）
                                qtyList: item.forecastPlanQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 3)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.stockSafetyLabel, // 供应商确认量（标识）
                                qtyList: item.stockSafety,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 4)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.targetInventoryQtyLabel, // 供应商确认量（标识）
                                qtyList: item.targetInventoryQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 5)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.coveredDaysLabel, // 供应商确认量（标识）
                                qtyList: item.coveredDays,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 6)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.supChainConfirmQtyLabel, // 供应商确认量（标识）
                                planConfirmLabel1: item.status, // 供应商确认量
                                qtyList: item.supChainConfirmQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 7)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.salePlanConfirmationQtyLabel, // 供应商确认量（标识）
                                qtyList: item.salePlanConfirmationQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 8)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.lastConfirmQtyLabel, // 供应商确认量（标识）
                                qtyList: item.lastConfirmQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 9)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.lastSalePlanConfirmQtyLabel, // 供应商确认量（标识）
                                qtyList: item.lastSalePlanConfirmQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 10)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.purchasePlanQtyLabel, // 供应商确认量（标识）
                                qtyList: item.purchasePlanQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 11)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.purchaseOrderQtyLabel, // 供应商确认量（标识）
                                qtyList: item.purchaseOrderQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 12)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.noFulfilPurchaseQtyLabel, // 供应商确认量（标识）
                                qtyList: item.noFulfilPurchaseQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 13)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.confirmedPurchaseOrderQtyLabel, // 供应商确认量（标识）
                                qtyList: item.confirmedPurchaseOrderQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 14)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.reservePurchaseQtyLabel, // 供应商确认量（标识）
                                qtyList: item.reservePurchaseQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 15)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.actualQtyLabel, // 供应商确认量（标识）
                                qtyList: item.actualQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 16)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.actualStorageQtyLabel, // 供应商确认量（标识）
                                qtyList: item.actualStorageQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 17)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.actualSalesQtyLabel, // 供应商确认量（标识）
                                qtyList: item.actualSalesQty,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }

                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 18)) {
                            newDataList.push({
                                channel: item.channel,
                                channelCode: item.channelCode,
                                warehouseName: item.warehouseName,
                                planTypeName: item.planTypeName,
                                warehouseCode: item.warehouseCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                storeCode: item.storeCode,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                category: item.category,
                                planConfirmLabel: item.realTimeInventoryLabel, // 供应商确认量（标识）
                                qtyList: item.realTimeInventory,            // 供应商确认量（数据）
                                flag: index,
                            });
                        }
                    });
                    this.dataList = newDataList
                }
                ,
                initFestivals() {
                    this.$refs.timeLine.vueComponent.festivalList = this.festivals
                    this.$refs.timeLine.vueComponent.initDate()
                }
                ,
                initEcharts(boo) {
                    let _this = this
                    _this.echartsLoading = true;
                    //基于准备好的dom，初始化echarts实例
                    if (boo) {
                        _this.dataForm1.startTime = boo[0]
                        _this.dataForm1.endTime = boo[1]
                    } else {
                        _this.dataForm1.startTime = _this.dataForm.startTime
                    }
                    _this.dataForm1.fatherChannelCodeList = _this.dataForm.fatherChannelCodeList
                    _this.dataForm1.planTypeList = _this.dataForm.planTypeList
                    _this.dataForm1.areaCodeList = _this.dataForm.areaCodeList
                    _this.dataForm1.categoryCodeList = _this.dataForm.categoryCodeList
                    _this.dataForm1.warehouseCodeList = _this.dataForm.warehouseCodeList
                    _this.$http({
                        url: "/scm-plan-admin/api/v1/requirements/eChartsData",
                        method: "POST",
                        data: _this.dataForm1
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            _this.labels = []
                            _this.serArr = []
                            _this.pplanTargetDTOS = []
                            if (data.data.labelData) {
                                result.data.data.labelData.forEach(e => {
                                    let str = {};
                                    str.key = e.key;
                                    str.label = e.label;
                                    _this.labels.push(e.label);
                                    _this.pplanTargetDTOS.push(str)
                                })
                                _this.dateList = result.data.data.dateList
                                _this.pplanTargetDTOS.forEach(str => {
                                    let obj = {};
                                    let key1 = str.key;
                                    obj.data = result.data.data.value[key1];
                                    obj.name = str.label;
                                    obj.type = "bar";
                                    _this.serArr.push(obj)
                                })
                            }
                        } else {
                            _this.echartsLoading = false;
                            _this.$message.error(result.data.msg);
                        }
                    }).then(e => {
                        _this.initOpentionEcharts()
                    })

                }
                ,
                initOpentionEcharts() {
                    let _this = this
                    let ec = null;
                    if (echarts != undefined) {
                        ec = echarts;
                    } else {
                        ec = window.echarts;
                    }
                    var myChart = ec.init(document.getElementById('echarts'));
                    let arr = {}
                    let arr2 = []
                    this.serArr.forEach(e => {
                        let obj = _this.value2.find(e1 => {
                            return e1 === e.name
                        })
                        if (obj) {
                            arr2.push(e)
                        }
                    })
                    let maxList = []
                    arr2.forEach(e => {
                        if (typeof e.data === 'undefined') {
                            maxList.push(0)
                        } else {
                            maxList.push(...e.data)
                        }
                    })
                    let option = {
                        color: ['#4BA2FD', '#5AD8A6', '#6DC8EC', '#945FB9'],
                        title: {
                            text: ''
                        },
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        dataZoom: [
                            {
                                show: true,
                                realtime: true,
                                start: 0,
                                end: 50
                            },
                            {
                                type: 'inside',
                                realtime: true,
                                start: 0,
                                end: 50
                            }
                        ],
                        legend: {
                            type: 'scroll',
                            orient: 'horizontal',
                            data: _this.value2,
                            selected: arr
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            data: _this.dateList,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        yAxis: [
                            {
                                type: 'value',
                                name: '量',
                                min: 0,
                                max: Math.max(...maxList) + Math.max(...maxList) * 0.1,
                                interval: parseInt((Math.max(...maxList) + Math.max(...maxList) * 0.1) / 5),
                                axisLabel: {
                                    formatter: '{value}'
                                }
                            }
                        ],
                        series: arr2
                    };
                    this.echartsLoading = false;
                    myChart.setOption(option, true);
                }
                ,
                offsetFun(val) {
                    let offSetNum = val.target.vueComponent.offSetNum
                    let obj = {
                        startTime: '',
                        endTime: ''
                    }
                    if (offSetNum === 16) {
                        obj.startTime = this.dateFormat('yyyy-MM-dd', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date),
                            obj.endTime = this.dateFormat('yyyy-MM-dd', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum].date1)
                    } else {
                        obj.startTime = this.dateFormat('yyyy-MM-dd', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date)
                        obj.endTime = this.dateFormat('yyyy-MM-dd', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum + 1].date)
                    }
                    this.dataForm.startTime = obj.startTime
                    this.dataList = []
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.getDataList()
                }
                ,
                changePicker(val) {
                    this.initEcharts(val)
                }
                ,
                searchList() {
                    let _this = this
                    this.dataList = []
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.dataForm.quota1 = this.dataForm.quota11
                    this.dataForm.categoryCodeList = []
                    this.$refs.tree.getCheckedNodes().forEach(e => {
                        _this.dataForm.categoryCodeList.push({
                            level: e.data.level,
                            code: e.data.code
                        })
                    })
                    let skuCodeS = _this.dataForm.skuCodeS;
                    if (skuCodeS && skuCodeS.length) {
                        let skuCode = skuCodeS.split(/[(\r\n)\r\n]+/);
                        skuCode.forEach(e => {
                            _this.dataForm.categoryCodeList.push({
                                level: 5,
                                code: e
                            })
                        })
                    }
                    // this.dataForm.channelCodeList = []
                    this.dataForm.areaCodeList = []
                    if (this.$refs.tree2) {
                        this.$refs.tree2.getCheckedNodes().forEach(e => {
                            _this.dataForm.areaCodeList.push({
                                level: e.data.level,
                                code: e.data.code
                            })
                        })
                    }
                    /*this.dataForm.layeredCodeList = []
                    if (this.dataForm.layeredCodes) {
                        this.dataForm.layeredCodes.forEach(e => {
                            this.dataForm.layeredCodeList.push(e)

                        })
                    }*/
                    this.getDataList()
                    this.dialogVisible = false
                    this.dialogFormVisible = false
                }
                ,
                advancedSearch() {
                    this.dialogVisible = true
                }
                ,
                initData() {
                    this.tableData = []
                    this.tables = this.rowData[0]['dates']
                    for (let i = 0; i < 10; i++) {
                        this.rowData.push(this.rowData[0])
                    }
                    this.rowData.forEach(e => {
                        let channelCode = e['channelCode']
                        let gmvTarget = e.gmvTargets
                        gmvTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let gmvRealTarget = e.gmvRealTargets
                        gmvRealTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let a = e.a
                        a.channelCode = channelCode
                        this.tableData.push(a)
                        let b = e.b
                        b.channelCode = channelCode
                        this.tableData.push(b)
                    })
                }
                ,
                clearCondition() {
                    this.dataForm.skuCodeS = null
                    this.dataForm.chanel = []
                    this.dataForm.area = []
                    this.dataForm.skuNodes = []
                    this.dataForm.quota11 = []
                    this.dataForm.layeredCodeList = []
                    //this.dataForm.fatherChannelCodeList = []
                    this.dataForm.warehouseCodeList = []
                    this.dataForm.planTypeList = []
                }
                ,
                sizeChangeHandle(val) {
                    this.pageSize = val;
                    this.pageIndex = 1;
                    this.totalCount = 0
                    this.getDataList();
                }
                ,
                currentChangeHandle(val) {
                    this.pageIndex = val;
                    this.getDataList();
                }
                ,
                fullScreen() {
                    let _this = this
                    _this.dialogVisible1 = true
                    if (_this.$refs.table && _this.$refs.table.selection && _this.$refs.table.selection.length) {
                        let selection = _this.$refs.table.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        _this.$nextTick(function () {
                            this.$refs.tablemax.clearSelection();
                            if (rows) {
                                rows.forEach(row => {
                                    _this.$refs.tablemax.toggleRowSelection(row, true);
                                });
                            }
                        });
                    }
                }
                ,
                leaveFullScreen() {
                    let _this = this
                    _this.dialogVisible1 = false
                    if (_this.$refs.tablemax && _this.$refs.tablemax.selection && _this.$refs.tablemax.selection.length) {
                        let selection = _this.$refs.tablemax.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        this.$refs.table.clearSelection();
                        if (rows) {
                            rows.forEach(row => {
                                _this.$refs.table.toggleRowSelection(row, true);
                            });
                        }
                    }
                },
                open(msg) {
                    this.$alert(msg, '提示', {confirmButtonText: '确定'});
                },
                command(val) {
                    let _this = this
                    //下标集合
                    _this.exportForm.rowIndex = []
                    //渠道集合
                    _this.exportForm.fatherChannelCodeList = _this.dataForm.fatherChannelCodeList
                    //计划类型
                    _this.exportForm.typeList = _this.dataForm.planTypeList
                    //仓库
                    _this.exportForm.warehouseCodeList = _this.dataForm.warehouseCodeList
                    //区域
                    _this.exportForm.areaCodeList = _this.dataForm.areaCodeList;
                    //品类
                    _this.exportForm.categoryCodeList = _this.dataForm.categoryCodeList;
                    //起始时间
                    _this.exportForm.startTime = _this.dataForm.startTime
                    //分页信息
                    _this.exportForm.pageSize = _this.pageSize;
                    _this.exportForm.pageNum = _this.pageIndex;
                    //是否编辑
                    _this.exportForm.edit = _this.dataForm.edit;
                    //TODO 单位
                    _this.exportForm.unitType = _this.dataForm.unitType
                    //TODO 分层
                    _this.exportForm.layeredCodeList = _this.dataForm.layeredCodeList

                    let boo = false
                    if (val === 2) {
                        let array = []
                        if (this.dialogVisible1) {
                            if (this.$refs.tablemax.selection && this.$refs.tablemax.selection.length > 0) {
                                this.$refs.tablemax.selection.forEach(e => {
                                    array.push(e.flag)
                                })
                            } else {
                                boo = true
                            }
                        } else {
                            if (this.$refs.table.selection && this.$refs.table.selection.length > 0) {
                                this.$refs.table.selection.forEach(e => {
                                    array.push(e.flag)
                                })
                            } else {
                                boo = true
                            }
                        }
                        this.exportForm.rowIndex = [...new Set(array)]
                    }
                    if (boo) {
                        this.$message({
                            message: '请选择至少一条数据',
                            type: 'error'
                        })
                        return false
                    }
                    const loading = this.$loading({
                        lock: true,
                        text: '下载中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    this.$http({
                        url: '/scm-plan-admin/api/v1/requirements/exportExcel',
                        method: 'post',
                        data: this.exportForm,
                        params: {type: val}
                    }).then(result => {
                        loading.close();
                        this.open(result.data.data);
                        /*let data = result.data;
                        let fileReader = new FileReader();
                        fileReader.onload = function () {
                            try {
                                let jsonData = JSON.parse(this.result);  // 说明是普通对象数据，后台转换失败
                                loading.close();
                                if (jsonData.msg) {
                                    _this.$message({
                                        message: jsonData.msg,
                                        type: 'error'
                                    })
                                }
                            } catch (err) {   // 解析成对象失败，说明是正常的文件流
                                const disposition = result.headers['content-disposition'];
                                let fileName = disposition.substring(disposition.indexOf('filename=') + 9, disposition.length);
                                fileName = decodeURIComponent(fileName);
                                let blob = new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
                                if ('download' in document.createElement('a')) { // 非IE下载
                                    const elink = document.createElement('a')
                                    elink.download = fileName
                                    elink.style.display = 'none'
                                    elink.href = URL.createObjectURL(blob)
                                    document.body.appendChild(elink)
                                    elink.click()
                                    URL.revokeObjectURL(elink.href) // 释放URL 对象
                                    document.body.removeChild(elink)
                                } else { // IE10+下载
                                    navigator.msSaveBlob(blob, fileName)
                                }
                                loading.close();
                            }
                        };
                        fileReader.readAsText(data, "utf-8")*/
                    }).catch(function (e) {
                        loading.close();
                    })
                }
                ,
                download(data) {
                    if (!data) {
                        return
                    }
                    let url = window.URL.createObjectURL(new Blob([data]))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', 'excel.xlsx')

                    document.body.appendChild(link)
                    link.click()
                }
                ,
                labelChange(val) {
                    this.initOpentionEcharts()
                }
                ,
                dateFormat(fmt, date) {

                    let ret;
                    const opt = {
                        "y+": date.getFullYear().toString(),        // 年
                        "M+": (date.getMonth() + 1).toString(),     // 月
                        "d+": date.getDate().toString(),            // 日
                        "H+": date.getHours().toString(),           // 时
                        "m+": date.getMinutes().toString(),         // 分
                        "s+": date.getSeconds().toString()          // 秒
                        // 有其他格式化字符需求可以继续添加，必须转化成字符串
                    };
                    for (let k in opt) {
                        ret = new RegExp("(" + k + ")").exec(fmt);
                        if (ret) {
                            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
                        }
                        ;
                    }
                    ;
                    return fmt;
                }
                ,
                findStyle({row, column, rowIndex, columnIndex}) {
                    if (column.label && typeof parseInt(column.label.substr(0, 1)) === 'number' && !isNaN(column.label.substr(0, 1))) {
                        return "padding: 0;background: #4ba2fd;color: #ffffff"
                    } else {
                        return "padding: 0;background: #f8f8f8"
                    }
                }
                ,//获取上一周的开始时间
                getBeginOflastWeek() {
                    let nowdate = new Date();
                    let oneweekdate = new Date(nowdate - 7 * 24 * 3600 * 1000);
                    let nowDayOfWeek = oneweekdate.getDay(); // 本周的第几天
                    let nowDay = oneweekdate.getDate(); // 当前日
                    let nowMonth = oneweekdate.getMonth(); // 当前月
                    let nowYear = oneweekdate.getFullYear(); // 当前年
                    let weekStartDate = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek == 0 ? 7 : nowDayOfWeek) + 1)
                    let y = weekStartDate.getFullYear();
                    // let m = String(weekStartDate.getMonth() + 1).length === 1 ? '0' + (weekStartDate.getMonth() + 1) : weekStartDate.getMonth() + 1;
                    // let d = String(weekStartDate.getDate()).length === 1 ? '0' + weekStartDate.getDate() : weekStartDate.getDate();
                    let m = weekStartDate.getMonth() + 1;
                    let d = weekStartDate.getDate();
                    let formatwdate = y + '-' + m + '-' + d;
                    return formatwdate;
                }
                ,
                /*点击单位触发事件*/
                commandUnit(val) {
                    this.defaultUnit = val.unitName
                    this.dataForm.unitType = val.unitType;
                    this.getDataList();
                    this.dataForm1.unitType = val.unitType;
                    // this.initEcharts();
                }
                ,
                indexContent(val) {
                    switch (val) {
                        case '销售计划量':
                            return '单品-全渠道每周销售计划数量总和'
                            break;
                        case '预测计划量':
                            return '单品-全渠道每周预测计划数量总和'
                            break;
                        case '安全库存量':
                            return '各RDC仓库安全库存量总和'
                            break;
                        case '本次供应链确认量':
                            return '全渠道本次供应链确认计划量总和'
                            break;
                        case '本次销售计划确认量':
                            return '全渠道本次确认计划量总和'
                            break;
                        case '上次供应链确认量':
                            return '全渠道上次供应链确认计划量总和'
                            break;
                        case '上次销售计划确认量':
                            return '全渠道上次确认计划量总和'
                            break;
                        case '预约在途采购量':
                            return '已执行预约的采购单量总和'
                            break;
                        case '实际销量':
                            return '当前每周实际销售量'
                            break;
                        case '未履约采购量':
                            return '未执行预约的采购单量总和'
                            break;
                        case '期末库存':
                            return '当前各RDC实时库存总和'
                            break;
                        default:
                            return ''
                    }
                }
                ,
                approve() {
                    if (!this.isEditMode) {
                        return
                    }
                    //整页的所有数据
                    let pageData = this.$refs.table.data;
                    //计算需要更新的下标值
                    let targetLength = this.targetOption.length;
                    let indexArr = [];
                    let itemElement;
                    this.$refs.table.selection.forEach(item => {
                        indexArr.push((item.flag * targetLength) + 5);
                    })
                    if (indexArr && indexArr.length > 0) {
                        this.$confirm('是否确认当前供应链数量?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            let arr = []
                            let body
                            let index = 0;
                            indexArr.forEach(item => {
                                itemElement = pageData[item];
                                itemElement.qtyList.forEach(subItem => {
                                    body = {}
                                    body.supplyChainConfirmationQty = subItem
                                    body.warehouseCode = itemElement.warehouseCode
                                    body.skuCode = itemElement.skuCode
                                    body.provinceCode = itemElement.provinceCode
                                    body.cityCode = itemElement.cityCode
                                    body.countyCode = itemElement.countyCode
                                    body.storeCode = itemElement.storeCode
                                    body.channelCode = itemElement.channelCode
                                    body.planStartDate = this.tmpStartDateList[index]
                                    arr.push(body)
                                    index++;
                                })
                                index = 0;
                            })
                            //调用编辑接口
                            this.dataListLoading = true;
                            this.$http({
                                url: 'scm-plan-admin/api/v1/requirements/confirmQty?unitType=' + this.dataForm.unitType,
                                method: 'POST',
                                data: arr
                            }).then(result => {
                                const data = result.data;
                                if (data && data.code === '0') {
                                    this.$message.success('编辑成功');
                                    this.$nextTick(e => {
                                        this.dataListLoading = false;
                                        this.getDataList()
                                    })
                                } else {
                                    this.$message.error(result.data.msg);
                                    this.dataListLoading = false;
                                }
                            }).catch(() => {
                                this.$message.error('编辑失败');
                                this.dataListLoading = false;
                            })
                        }).catch(() => {
                            this.$message({
                                type: 'info',
                                message: '已取消确认'
                            });
                        });
                    } else {
                        this.$message.error('请至少选择一条数据');
                    }
                }
                ,
                approve1() {
                    if (!this.isEditMode) {
                        return
                    }
                    //整页的所有数据
                    let pageData = this.$refs.tablemax.data;
                    //计算需要更新的下标值
                    let targetLength = this.targetOption.length;
                    let indexArr = [];
                    let itemElement;
                    this.$refs.tablemax.selection.forEach(item => {
                        indexArr.push((item.flag * targetLength) + 5);
                    })
                    if (indexArr && indexArr.length > 0) {
                        this.$confirm('是否确认当前供应链数量?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            let arr = []
                            let body
                            let index = 0;
                            indexArr.forEach(item => {
                                itemElement = pageData[item];
                                itemElement.qtyList.forEach(subItem => {
                                    body = {}
                                    body.supplyChainConfirmationQty = subItem
                                    body.warehouseCode = itemElement.warehouseCode
                                    body.skuCode = itemElement.skuCode
                                    body.provinceCode = itemElement.provinceCode
                                    body.cityCode = itemElement.cityCode
                                    body.countyCode = itemElement.countyCode
                                    body.storeCode = itemElement.storeCode
                                    body.channelCode = itemElement.channelCode
                                    body.planStartDate = this.tmpStartDateList[index]
                                    arr.push(body)
                                    index++;
                                })
                                index = 0;
                            })
                            //调用编辑接口
                            this.dataListLoading = true;
                            this.$http({
                                url: 'scm-plan-admin/api/v1/requirements/confirmQty?unitType=' + this.dataForm.unitType,
                                method: 'POST',
                                data: arr
                            }).then(result => {
                                const data = result.data;
                                if (data && data.code === '0') {
                                    this.$message.success('编辑成功');
                                    this.getDataList()
                                } else {
                                    this.$message.error(result.data.msg);
                                    this.dataListLoading = false;
                                }
                            }).catch(() => {
                                this.$message.error('编辑失败');
                                this.dataListLoading = false;
                            })
                        }).catch(() => {
                            this.$message({
                                type: 'info',
                                message: '已取消确认'
                            });
                        });
                    } else {
                        this.$message.error('请至少选择一条数据');
                    }
                },
                editMode() {
                    //渠道置空
                    this.dataForm.fatherChannelCodeList = []
                    //仓库
                    this.dataForm.warehouseCodeList = []
                    //计划类型
                    this.dataForm.planTypeList = []
                    //区域
                    this.dataForm.areaCodeList = []
                    //品类
                    this.dataForm.categoryCodeList = []
                    this.isEditMode = false
                    this.dataForm.edit = false
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.getDataList()
                },
                browseMode() {
                    this.isEditMode = true
                    //DTO的字段变成不需要区域字段，
                    this.dataForm.edit = true
                    this.dataForm.skuCodeS = ''
                    this.dataForm.chanel = []
                    this.dataForm.area = []
                    this.dataForm.skuNodes = []
                    this.dataForm.quota11 = []
                    this.dataForm.layeredCodeList = []
                    //渠道置空
                    this.dataForm.fatherChannelCodeList = []
                    //仓库
                    this.dataForm.warehouseCodeList = []
                    //计划类型
                    this.dataForm.planTypeList = []
                    //区域
                    this.dataForm.areaCodeList = []
                    //品类
                    this.dataForm.categoryCodeList = []
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.getDataList()
                }
            },
            template: `
    <div>
                <el-card class="box-card">
                <el-dialog  :visible.sync="chooseGoodsDialog" title="任务列表"  width="80%" :modal="true">
            <span>
            <scmPlanCommonChoosegoods v-if="chooseGoodsDialog" ref="scmPlanCommonChoosegoods"  @closeChooseGoodsDialog="closeChooseGoodsDialog"></plan-common-choosegoods>
          </span>
        </el-dialog>
              <div slot="header" class="clearfix">
                <div style="text-align: right;margin: 5px">
                <span style="float: left;color: rgba(0,0,0,0.85);font-size: 16px;line-height:35px">时间范围</span>
                <el-button  size="small"  style="float: left;margin-left: 10px"  @click="fullScreen" >全屏</el-button>
                 <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" style="text-align: left" width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-row>
                 <el-form :inline="true" label-width="100px" :model="dataForm"  size="small"  class="demo-form-inline">
                 <el-row>
                  <el-col :span="8">
                       <el-form-item v-if="!isEditMode" label="渠道选择:">
                      <el-select v-model="dataForm.fatherChannelCodeList" multiple  placeholder="请选择">
    <el-option
      v-for="item in channelList"
      :key="item.code"
      :label="item.name"
      :value="item.code">
    </el-option>
  </el-select>
   </el-form-item>
                      </el-col>
                        <el-col :span="8">
                              <el-form-item v-if="!isEditMode"  label="计划类型选择:">
                              <el-select v-model="dataForm.planTypeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="(key,value) in planTypeList"
                                  :key="value"
                                  :label="key"
                                  :value="value"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
                      <el-col :span="8">
                      <el-form-item v-if="!isEditMode" label="区域选择:">
                     <el-cascader 
                    v-model="dataForm.area"
                    :props="props2" ref="tree2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>
</el-row> <el-row>
<el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props" ref="tree" v-model="dataForm.skuNodes"></el-cascader>
                      </el-form-item>
                      </el-col>
<el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
                              @input="$forceUpdate()"
                              :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
                              v-model="dataForm.skuCodeS"
                              clearable></el-input>
                            </el-form-item>
                            </el-col>
                            <el-col :span="8">
                              <el-form-item label="仓库选择:">
                              <el-select v-model="dataForm.warehouseCodeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="item in warehouseList"
                                  :key="item.code"
                                  :label="item.code+'-'+item.name"
                                  :value="item.code"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
</el-row>
<!--<el-row>

                            <el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)">
                                    <el-select  style="width:100%" @change="dataForm.layeredCodes = []" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                              <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="((dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)) && dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodes">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>--><el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  </el-dialog>
                    <el-button v-if="isEditMode" size="small" @click="editMode">查看</el-button>
                    <el-button v-if="!isEditMode" size="small" @click="browseMode">编辑</el-button>
                  <el-button v-if="isEditMode" size="small" @click="approve">审核</el-button>
                    <el-button size="small" type="primary" style="margin-right: 5px;" @click="dialogVisible3 = true">导入</el-button>
                  <el-dropdown @command="command">
                      <el-button type="primary"  size="small" >
                        导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                        <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                        <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>   
                    <el-button size="small" type="primary"  @click="choiceAllocationDetail">任务列表</el-button>
                       <el-dropdown @command="commandUnit">
                      <el-button type="info" size="small" style="margin-left: 5px;">
                         {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                    </el-dropdown>
             </div>
              </div>
                  <el-dialog title="导入引导" :visible.sync="dialogVisible3" :close-on-click-modal="false" :beforeClose="handleClose" width="700px">
                    <el-steps :active="activeStep" align-center>
                        <el-step title="上传文档"></el-step>
                        <el-step title="导入并校验"></el-step>
                        <el-step title="创建完成"></el-step>
                    </el-steps>
                    <div v-show="activeStep !== 3">
                        <div>
                            <div style="color:red;">注意事项:</div>
                            <p>（1）模板中的标题不可更改，标题行不可删除；</p>
                            <p>（2）除必填的列以外，不需要的列可以删除；</p>
                            <p>（3）单次导入的数据不超过20000条；</p>
                        </div>
                    </div>
                    <div v-show="activeStep === 1">
                        2. 请选择要导入的数据文件。
                        <el-upload :on-change="handleChangeUpload" accept=".xls,.xlsx" :show-file-list="false" :auto-upload="false" class="upload-demo" style="padding:5px 18px;" action="https://jsonplaceholder.typicode.com/posts/" :limit="1" :file-list="fileList">
                            <el-button size="small" type="primary"><i class="el-icon-plus"></i>&nbsp;选择文件</el-button>
                            <div slot="tip" class="el-upload__tip" style="color:#ccc;">请选择excel文件，允许上传附件类型（xls,xlsx），文件大小不得大于100MB</div>
                        </el-upload>
                    </div>
                    <div class="file-list" v-show="fileList.length > 0">
                        <div class="file-list__item" style="marginTop:20px;padding:10px 20px;backgroundColor: #eaeaea;display:flex;justifyContent: space-between;" v-for="item in fileList" :key="item.name">
                            <div>{{item.name}}</div>
                            <div>{{(item.size/1024).toFixed(2)}}KB</div>
                            <div>完成</div>
                        </div>
                    </div>
                    <div slot="footer" class="dialog-footer" style="text-align:center;">
                        <el-button type="primary" @click.native="submitUpload" :disabled="activeStep===1" v-show="activeStep !==3">开始导入</el-button>
                        <el-button @click.native="onClickCancelBtn" v-show="activeStep !==3">{{cancelBtnText}}</el-button>
                        <el-button @click="resetBtn" v-if="activeStep != 1">重置</el-button>
                        <el-button @click.native="onClickCancelBtn" v-show="activeStep ===3">关闭</el-button>
                    </div>
                    <p style="text-align: center;color:red;margin-top:10px;" v-if="activeStep === 2 && (importErrInfo != '' && importErrInfo != null)">{{importErrInfo}}</p>
                </el-dialog>
            <time-line ref="timeLine" @offsetFun="offsetFun"></time-line>
            <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
            <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                center
                ref="table"
                  v-if="dataList.length"
                border
                v-loading="dataListLoading"
                highlight-current-rows
                height="33vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
           <el-table-column
            width="130"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                    <template slot-scope="scope">
                        {{scope.row.channel}}
                    </template>
                </el-table-column>
                <el-table-column
            width="130"
                  prop="planTypeName"
                  fixed="left"
                  label="计划类型" align="left">
                    <template slot-scope="scope">
                        {{scope.row.planTypeName}}
                    </template>
                </el-table-column>
                <el-table-column
                    width="130"
                    prop="warehouseName"
                  fixed="left"
                  label="仓库" align="left">
                  <template slot-scope="scope">
                    {{scope.row.warehouseName != null ?  scope.row.warehouseName + "/" + scope.row.warehouseCode : ""}}                  
                    </template>
                </el-table-column>
                
                <el-table-column
                width="130"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
                <el-table-column
                  prop="category"
                  width="130"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="130"
                  label="商品" align="left">
                  <template slot-scope="scope">
                  {{scope.row.skuName != null ? scope.row.skuName + "/" + scope.row.skuCode : ""}}                   
                  </template>
                </el-table-column>
                <el-table-column
                width="130"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                   <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
            <el-table-column
              v-for="(week, index) in weekDate" :label="week"
               width="120" align="right">
               <template slot-scope="scope">
                  <input type="number" v-if="scope.row.planConfirmLabel == '本次供应链确认量'" :disabled="scope.row.planConfirmLabel1[index] == 0 || !isEditMode" size="mini" v-model="scope.row.qtyList[index]">
                  <span v-else>{{(scope.row.qtyList[index] == 0 || scope.row.qtyList[index] == null)? '-' : scope.row.qtyList[index] }}</span>
              </template>
               </el-table-column>
        </el-table>
            <div style=";width: 100%;">
                <div style="height: 30px;width: 1px"></div>
                <el-row>
                 <span style="margin-left: 20px">日期范围</span>
                <el-date-picker
                  v-model="value1"
                  @change="changePicker"
                  type="daterange"
                  size="mini"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  align="right"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions">  
                </el-date-picker>
                <el-select v-model="value2" size="mini" clearable collapse-tags :multiple-limit="4" multiple placeholder="请选择指标" @change="labelChange">
                    <el-option
                      v-for="item in labels"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                 <el-pagination
                 background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                 :page-count="totalPage"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
                </el-row>
                <div  v-loading="echartsLoading" style="margin-top: 20px;height: 30vh;width: 100%;" id="echarts"></div>
            </div>
            </el-card>
        <el-dialog
          center
          :style="{ padding: '0px' }"
          fullscreen
          :show-close="false"
          :visible.sync="dialogVisible1">
           <div style="">
           <div style="text-align: right;margin: 5px">
           <el-button  size="small" style="float: left;margin-left: 10px" @click="leaveFullScreen">退出全屏</el-button>
           <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" append-to-body style="text-align: left" width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-row>
                 <el-form :inline="true" label-width="100px" :model="dataForm"  size="small"  class="demo-form-inline">
                 <el-row>
                  <el-col :span="8">
                      <el-form-item v-if="!isEditMode" label="渠道选择:">
                      <el-select v-model="dataForm.fatherChannelCodeList" multiple placeholder="请选择">
    <el-option
      v-for="item in channelList"
      :key="item.code"
      :label="item.name"
      :value="item.code">
    </el-option>
  </el-select>
   </el-form-item>
                      </el-col>
                       <el-col :span="8">
                              <el-form-item v-if="!isEditMode" label="计划类型选择:">
                              <el-select v-model="dataForm.planTypeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="(key,value) in planTypeList"
                                  :key="value"
                                  :label="key"
                                  :value="value"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
                      <el-col :span="8">
                      <el-form-item v-if="!isEditMode" label="区域选择:">
                     <el-cascader
                    v-model="dataForm.area"
                    :props="props2" ref="tree2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>
</el-row> <el-row>
<el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props" ref="tree" v-model="dataForm.skuNodes"></el-cascader>
                      </el-form-item>
                      </el-col>
 <el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
                              @input="$forceUpdate()"
                              :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
                              v-model="dataForm.skuCodeS"
                              clearable></el-input>
                            </el-form-item>
                            </el-col>
                            <el-col :span="8">
                              <el-form-item label="仓库选择:">
                              <el-select v-model="dataForm.warehouseCodeList" multiple clearable filterable style="width: 100%">
                                  <el-option
                                  v-for="item in warehouseList"
                                  :key="item.code"
                                  :label="item.code+'-'+item.name"
                                  :value="item.code"
                                  ></el-option>
                              </el-select>
                            </el-form-item>
                            </el-col>
</el-row>
<!--<el-row>
<el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)">
                                    <el-select  style="width:100%" @change="dataForm.layeredCodes = []" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                              <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="((dataForm.channelCodes && dataForm.channelCodes.length) || (dataForm.area && dataForm.area.length)) && dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodes">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>--><el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  
</el-dialog>
  <el-button v-if="isEditMode" size="small" @click="editMode">查看</el-button>
                    <el-button v-if="!isEditMode" size="small" @click="browseMode">编辑</el-button>
                <el-button v-if="isEditMode" size="small" @click="approve1">审核</el-button>
                 <el-button size="small" type="primary" style="margin-right: 5px;" @click="dialogVisible3 = true">导入</el-button>
                 <el-dropdown @command="command">
                      <el-button size="small" type="primary" >
                        导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                        <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                        <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                    <el-button size="small" type="primary"  @click="choiceAllocationDetail">任务列表</el-button>
                       <el-dropdown @command="commandUnit">
                      <el-button type="info" size="small" style="margin-left: 5px;">
                         {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                    </el-dropdown>
                    </div>
                    <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
                <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                center
                ref="tablemax"
                border
                v-if="dataList.length"
                v-loading="dataListLoading"
                highlight-current-rows
                height="85vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
           <el-table-column
            width="130"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                <template slot-scope="scope">
                        {{scope.row.channel}}
                    </template>
                </el-table-column>
                <el-table-column
            width="130"
                  prop="planTypeName"
                  fixed="left"
                  label="计划类型" align="left">
                    <template slot-scope="scope">
                        {{scope.row.planTypeName}}
                    </template>
                </el-table-column>
                1<el-table-column
                    width="130"
                  fixed="left"
                    prop="warehouseName"
                  label="仓库" align="left">
                  <template slot-scope="scope">
                   {{scope.row.warehouseName != null ?  scope.row.warehouseName + "/" + scope.row.warehouseCode : ""}}             
                    </template>
                </el-table-column>
                <el-table-column
                width="130"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
                <el-table-column
                  prop="category"
                  width="130"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="130"
                  label="商品" align="left">
                  <template slot-scope="scope">
                      {{scope.row.skuName != null ? scope.row.skuName + "/" + scope.row.skuCode : ""}}
                  </template>
                </el-table-column>
                <el-table-column
                width="130"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                    <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
             <el-table-column
              v-for="(week, index) in weekDate" :label="week"
               width="120" align="right">
               <template slot-scope="scope">
                  <input type="number" v-if="scope.row.planConfirmLabel == '本次供应链确认量'" size="mini" :disabled="scope.row.planConfirmLabel1[index] == 0 || !isEditMode" v-model="scope.row.qtyList[index]">
                  <span v-else>{{(scope.row.qtyList[index] == 0 || scope.row.qtyList[index] == null)? '-' : scope.row.qtyList[index] }}</span>
              </template>
               </el-table-column>
        </el-table>
          <el-pagination
                 background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
           </div>
          <span slot="footer" class="dialog-footer">
          </span>
        </el-dialog>

    </div>
    `
        }
    );
})
;